package main.test.SparkAPI.Baics.traits
// Implement a class Cat that extends the trait Animal

/**
 * can also extend more than one interface at the same time.
 * you can difne a Dog class to represent an animal with a name.
 */
class Cat extends Animal {
  override val sleep = "sleepy cat!"
  def eat(food: String) = s"the cat is eating $food"
  def move(x: Int, y: Int) = s"the cat is moving to ($x,$y)"
}

/**
 * In scala, values and varables can implement or override functions with no paremeters
 * and no paretheses
 *
 */
class MyPrinter(val name :String) extends Printable with TestName {
  override def print: Unit = {
    println("hello"+name)
  }

//  override def name: String = strs
}
//Dog class
//The keyword val marks the field name of
//the class Dog as publicly accessible.
class Dog(val name:String) extends Animal with Nameable {
//class Dog(val name:String) extends Animal  {
  def eat(food: String) = s"$food, $food"

  override def move(x: Int, y: Int): String = s"lets go to ($x $y)"

  /**
   * The trait Nameable requires your class to implement def name:String,
   * a method without parameters and without parentheses called name that returns
   * a string. The class Dog defines a publicly accessible field called name,
   * which is considered a valid implementation for def name:String
   * In scala, values and varables can implement or override functions with no paremeters
   * and no paretheses
   */
}
object testTraits {
  /**
   * Declare an interface using a trait
   * Implement classes objects and traits that conform to one
   * or more interfaces
   * Define a closed set of values using sealed traits
   *
   */

  /**
   * Now that youve discovered singleton objects in lesson 11,
   * lets leran about traits.Earlier in this book, you savw that
   * a class can hvae up to one superclass; you cannot express multople
   * inheritance using classed and abstract classes.
   * Traits are very similar to abstract classed but wiht a fundamental difference:
   * a class can inherit from one or more traits.
   * You can use them to express multiple inheritance;
   * you cannot achieve the same with abstract classes.
   * You can use traits to define interfaces to represent a set of features
   * hen the name traits that your class must have.
   * This is crucial object-oriented concept htat you
   * find in many languages, such as Go, Kotlin and java.In future units,
   * you will learn that traits are a lot more than just a way of express an
   * an interface: you'll see some of their superpowers and why this makes them a more expressive
   * and powerful tool. In this lesson, you'll discvoer hwo to create a trait and implement classes, object, and
   * other interfaces that conform to one or more interfaces.
   * You'll alse learn about
   * sealed traits: they allow you to define closed set of implementations for you interface
   * that compiler guarantees at compile time.
   * You'll finally discover the enumeration syntax that scala 3
   * introduces as an alternatvie to sealed traits.
   * In the capstone, you'll use the App trait to implement the entry point of your application.
   * @param args
   */




  def main(args: Array[String]): Unit = {

    val tiggerTheDog = new Dog("Tigger")
    println(tiggerTheDog.name)

  }

}
